#include "BankAccount.h"
#include <numeric>
#include <algorithm>
namespace BncImb {
namespace Domain {
using namespace std;
double BankAccount::balance() const {
  double sum = 0;
  for (auto& trans : mTransactions) {
    sum += trans.value();
  }

  return sum;
}

const string& BankAccount::code() const {
  return mCode;
}

const vector<Transaction>& BankAccount::transactions() const {
  return mTransactions;
}

void BankAccount::makeTransaction(double value, const string& sourceAccountCode) {
  mTransactions.emplace_back(value, sourceAccountCode);
}
}
}